package com.example.a10928.weifriend.adapter;

import android.widget.ImageView;
import android.widget.ProgressBar;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.a10928.weifriend.R;
import com.example.a10928.weifriend.http.api.base.ActivityShopBean;
import com.example.a10928.weifriend.http.api.base.MyAdertBean;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;
import java.util.List;

public class ActiveCenterAdapter extends BaseQuickAdapter<ActivityShopBean.DataBean, BaseViewHolder> {

    String t;
    public ActiveCenterAdapter(int layoutResId, ArrayList<ActivityShopBean.DataBean> data, String type) {
        super(layoutResId, data);
        t=type;
    }

    @Override
    protected void convert(BaseViewHolder helper, ActivityShopBean.DataBean item) {

        Picasso.with(mContext).load(item.getImages().get(0).getImg_url()).into((ImageView) helper.getView(R.id.iv));

        helper.setText(R.id.tv_title,item.getTitle());

        if(t.equals("1")){
            helper.setText(R.id.tv_btn,"立即参与");


        }else if(t.equals("2")){
            helper.setText(R.id.tv_btn,"查看中奖");
            helper.setText(R.id.tv_content,"已开奖 "+"总份额："+item.getNeed_people()
                    +"份");
        }else if(t.equals("3")){
            helper.setText(R.id.tv_btn,"查看详情");

        }
        if(item.getJoin_people()==item.getNeed_people()){
            helper.setText(R.id.tv_content,"已开奖 "+"总份额："+item.getNeed_people()
                    +"份");
        }else{
            helper.setText(R.id.tv_content,"夺宝进度 "+(100*item.getJoin_people()/item.getNeed_people())+"%   "+"总份额："+item.getNeed_people()
                    +"份");
        }

        ((ProgressBar)helper.getView(R.id.pb)).setProgress(100*item.getJoin_people()/item.getNeed_people());


    }
}
